﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Wicresoft.EKA.AccountInfoUpdateApp.Init
{
    public static class SysLog
    {
        public static void WriteSysLog(string sm)
        {
            Wicresoft.SelfService.BL.ITServiceHelper helper = new Wicresoft.SelfService.BL.ITServiceHelper();

            if (File.Exists(Environment.CurrentDirectory + @"\\SysLog\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt"))
            {
                StreamWriter sw = new StreamWriter(Environment.CurrentDirectory + @"\\SysLog\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt", true);
                sw.WriteLine("=======================================================================================");
                sw.WriteLine("Time:" + DateTime.Now.ToString("yyyyMMdd") + ": Message:" + sm);
                sw.WriteLine("=======================================================================================");
                sw.WriteLine("\r");
                sw.Close();
                return;
            }
            else
            {
                File.Create(Environment.CurrentDirectory + @"\\SysLog\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt");
                StreamWriter sw2 = new StreamWriter(Environment.CurrentDirectory + @"\\SysLog\\" + DateTime.Now.ToString("yyyyMMdd") + ".txt", true);
                sw2.WriteLine("=======================================================================================");
                sw2.WriteLine("Time:" + DateTime.Now.ToString("yyyyMMdd") + ": Message:" + sm);
                sw2.WriteLine("=======================================================================================");
                sw2.WriteLine("\r\n");
                sw2.Close();
                return;
            }
        }

    }
}
